<?php $post = $this->get('post');?>
<form method="post" action="<?php _actionUrl($this)?>" onsubmit="return ajax_form(this)">
<input type="hidden" value="<?php _e($post['ID'])?>" name="ID"/>
<div class="x-list-title">
<table width="100%" border="0" height="100%">
<tr>
	<td align="left">
		<h2>Sửa thông tin người dùng</h2>
	</td>
	<td align="right"></td>
</tr>
</table>	
</div>
<div class="x-form-container">
<table border="0" cellpadding="5" class="x-form">	
	<tr class="row-message">
		<td colspan="2">
			<div class="form-message"></div>
		</td>
	</tr>
	<tr>
		<td width="180" class="x-form-label">
			Tên tài khoản: 
		</td>
		<td class="x-form-input">
			<input name="username" type="text" style="width:200px" class="x-text" value="<?php _e($post['username']);?>"/>
		</td>
	</tr>
	<tr>	
		<td class="x-form-label">
			Mật khẩu: 
		</td>
		<td class="x-form-input">
			<input name="password" type="password" style="width:200px" class="x-text u-pas" value="" disabled/>&nbsp;<input name="changepass" value="yes" type="checkbox" onclick="$(this.parentNode.parentNode.parentNode).find('.u-pas').set('disabled',!this.checked)"/> Thay đổi mật khẩu
		</td>
	</tr>
	<tr>	
		<td class="x-form-label">
			Xác nhận lại:  
		</td>
		<td class="x-form-input">
			<input type="password" name="re_password" style="width:200px" class="x-text u-pas" value="" disabled/>
		</td>
	</tr>
	<tr>	
		<td class="x-form-label">
			Email: 
		</td>
		<td class="x-form-input">
			<input type="text" name="email" class="x-text" value="<?php _e($post['email']);?>" style="width:300px"/>
		</td>
	</tr>
	<tr>	
		<td class="x-form-label">
			Họ tên: 
		</td>
		<td class="x-form-input">
			<input type="text" name="fullname" class="x-text" value="<?php _e($post['fullname']);?>" style="width:300px"/>
		</td>
	</tr>
	<tr>	
		<td class="x-form-label">
			Di động: 
		</td>
		<td class="x-form-input">
			<input type="text" name="phone" class="x-text" value="<?php _e($post['phone']);?>" style="width:300px"/>
		</td>
	</tr>	
	<tr>	
		<td  class="x-form-label">
			Hồ sơ nhân sự: 
		</td>
		<td>
			<select name="personnel_id" class="x-select" style="width:150px">
				<option value="0">Không chọn</option>
				<?php	foreach($this->get('personnels') as $k => $v ):?>
					<option value="<?php _e($v['ID']);?>"<?php $v['ID']==$post['personnel_id'] ? _e(' selected'):''?>><?php _e($v['name']);?></option>
				<?php endforeach;?>
		</select>
		</td>
	</tr>
	<tr>	
		<td class="x-form-label">
			Nhóm người dùng:
		</td>
		<td>
		<select name="group_id" class="x-select" style="width:200px">
			<option value="0">Chọn nhóm người dùng</option>
			<?php	foreach($this->get('groups') as $k => $v ):?>
				<option value="<?php _e($v['ID']);?>"<?php $v['ID']==$post['group_id'] ? _e(' selected'):''?>><?php _e($v['title']);?></option>
			<?php endforeach;?>
		</select>
		</td>
	</tr>
	<tr>	
		<td class="x-form-label">
			Phòng ban:
		</td>
		<td>
			<select name="department_id" class="x-select" style="width:200px">
			<?php _e( select_options( $this->get('departments'), 'title', $post['department_id']) );?>	
			</select>
		</td>
	</tr>
	<tr>	
		<td class="x-form-label">
			Phân quyền:
		</td>
		<td>	
			<?php $roles = explode(",",$post['roles']);?>
			<div>
			<div style="padding:10px 0px;color:red">
			<input type="hidden" name="inherit_roles" value="yes"/>
			<label for="inherit_roles">
				<input type="checkbox" name="inherit_roles" onclick="$(this.parentNode.parentNode.parentNode).find('table input[type=checkbox]').set('disabled',!this.checked)" value="no"<?php $post['inherit_roles']=='no' ? _e(' checked'):''?>/> Tùy chỉnh lại quyền </label>
			</div>
			<table width="100%" style="background:#fff" border="1" bordercolor="#cccccc" cellpadding="0">
				<tr>
					<td valign="top" height="100">
						<table width="200" cellpadding="5">
							<tr class="role-section">
								<td align="center" width="10">
									<input type="checkbox" onclick="$(this).parent('table').slice(0,1).find('input[name*=roles]').set('checked',this.checked)"<?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/>
								</td>
								<td>Hệ thống</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="login"<?php in_array( 'login', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Truy cập</td>
							</tr>						
							<tr>
								<td><input type="checkbox" name="roles[]" value="email"<?php in_array( 'email', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Email</td>
							</tr>						
							<tr>
								<td><input type="checkbox" name="roles[]" value="message"<?php in_array( 'message', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Tin nhắn</td>
							</tr>						
							<tr>
								<td><input type="checkbox" name="roles[]" value="yahoo"<?php in_array( 'yahoo', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Chát</td>
							</tr>												
							<tr>
								<td><input type="checkbox" name="roles[]" value="manage_admin"<?php in_array( 'manage_admin', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Quản trị hệ thống</td>
							</tr>						
							<tr>
								<td><input type="checkbox" name="roles[]" value="manage_news"<?php in_array( 'manage_news', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Quản trị tin tức</td>
							</tr>						
							<tr>
								<td><input type="checkbox" name="roles[]" value="manage_forum"<?php in_array( 'manage_forum', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Quản trị diễn đàn</td>
							</tr>						
						</table>					
					</td>
					<td valign="top">
						<table width="200" cellpadding="5">
							<tr class="role-section">
								<td align="center" width="10">
									<input type="checkbox" onclick="$(this).parent('table').slice(0,1).find('input[name*=roles]').set('checked',this.checked)"<?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/>
									</td>
								<td>Dự án / công việc</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="task"<?php in_array( 'task', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Truy cập</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="add_project"<?php in_array( 'add_project', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Tạo dự án</td>
							</tr>						
							<tr>
								<td><input type="checkbox" name="roles[]" value="add_task"<?php in_array( 'add_task', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Tạo công việc</td>
							</tr>						
						</table>						
					</td>
					<td valign="top">
						<table width="200" cellpadding="5">
							<tr class="role-section">
								<td align="center" width="10">
									<input type="checkbox" onclick="$(this).parent('table').slice(0,1).find('input[name*=roles]').set('checked',this.checked)"<?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/>
								</td>
								<td>Công văn</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="diploma"<?php in_array( 'diploma', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Truy cập</td>
							</tr>							
							<tr>
								<td><input type="checkbox" name="roles[]" value="add_diploma"<?php in_array( 'add_diploma', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Tạo công văn</td>
							</tr>						
						</table>					
					</td>
					<td valign="top">
						<table width="200" cellpadding="5">
							<tr class="role-section">
								<td align="center" width="10">
									<input type="checkbox" onclick="$(this).parent('table').slice(0,1).find('input[name*=roles]').set('checked',this.checked)"<?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/>
								</td>
								<td>Tài liệu</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="document"<?php in_array( 'document', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Truy cập</td>
							</tr>							
							<tr>
								<td><input type="checkbox" name="roles[]" value="add_document"<?php in_array( 'add_document', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Tạo tài liệu</td>
							</tr>				
						</table>								
					</td>
				</tr>
				<tr>
					<td valign="top">
						<table width="200" cellpadding="5">
							<tr class="role-section">
								<td align="center" width="10">
									<input type="checkbox" onclick="$(this).parent('table').slice(0,1).find('input[name*=roles]').set('checked',this.checked)"<?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/>
								</td>
								<td>Nhân sự</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="personnel"<?php in_array( 'personnel', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Truy cập</td>
							</tr>
						</table>						
					</td>
					<td valign="top">
						<table width="200" cellpadding="5">
							<tr class="role-section">
								<td align="center" width="10">
									<input type="checkbox" onclick="$(this).parent('table').slice(0,1).find('input[name*=roles]').set('checked',this.checked)"<?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/>
								</td>
								<td>Lịch biểu</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="calendar"<?php in_array( 'login', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Truy cập</td>
							</tr>	
							<tr>
								<td><input type="checkbox" name="roles[]" value="add_private_calendar"<?php in_array( 'add_private_calendar', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Thêm lịch cá nhân</td>
							</tr>	
							<tr>
								<td><input type="checkbox" name="roles[]" value="add_company_calendar"<?php if( in_array('add_company_calendar',$roles)) _e(' checked');?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Thêm lịch cơ quan</td>
							</tr>								
						</table>						
					</td>
					<td valign="top">
						<table width="200" cellpadding="5">
							<tr class="role-section">
								<td align="center" width="10">
									<input type="checkbox" onclick="$(this).parent('table').slice(0,1).find('input[name*=roles]').set('checked',this.checked)"<?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/>
								</td>
								<td>CRM</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="crm"<?php in_array( 'crm', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Truy cập</td>
							</tr>	
							<tr>
								<td><input type="checkbox" name="roles[]" value="crm_admin"<?php in_array( 'crm_admin', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Quản lý</td>
							</tr>	
						</table>	
					</td>
					<td valign="top">
						<table width="200" cellpadding="5">
							<tr class="role-section">
								<td align="center" width="10">
									<input type="checkbox" onclick="$(this).parent('table').slice(0,1).find('input[name*=roles]').set('checked',this.checked)"<?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/>
								</td>
								<td>Tài sản</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="asset"<?php in_array( 'asset', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Truy cập</td>
							</tr>	
							<tr>
								<td><input type="checkbox" name="roles[]" value="manage_asset"<?php in_array( 'manage_asset', $roles) ? _e(' checked'):'' ?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Quản lý</td>
							</tr>	
						</table>			
					</td>
				</tr>
				<tr>
					<td valign="top">
						<table width="200" cellpadding="5">
							<tr class="role-section">
								<td align="center" width="10">
									<input type="checkbox" onclick="$(this).parent('table').slice(0,1).find('input[name*=roles]').set('checked',this.checked)"<?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/>
								</td>
								<td>Danh bạ</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="contact_company"<?php if( in_array('contact_company',$roles)) _e(' checked');?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Xem danh bạ cơ quan</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="contact_share"<?php if( in_array('contact_share',$roles)) _e(' checked');?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Xem danh bạ chia sẻ</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="contact_person"<?php if( in_array('contact_person',$roles)) _e(' checked');?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Quản lý danh bạ cá nhân</td>
							</tr>
							<tr>
								<td><input type="checkbox" name="roles[]" value="contact_company_manage"<?php if( in_array('contact_company_manage',$roles)) _e(' checked');?><?php $post['inherit_roles']=='yes' ? _e(' disabled'):''?>/></td>
								<td>Quản lý danh bạ cơ quan</td>
							</tr>
						</table>						
					</td>
					<td valign="top">
					</td>
					<td valign="top">
					</td>
					<td valign="top">
					</td>
				</tr>				
			</table></div>
			</td>
	</tr>
	<tr>	
		<td class="x-form-label"></td>
		<td>
			<input type="submit" value="Xác nhận" class="x-button x-save"/>
			<input type="reset"  value="Làm mới" class="x-button x-fresh"/>
		</td>
	</tr>
</table>
</div>
</form>